package com.ronx.scs.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.nio.channels.FileChannel;

public class FileUtils {

    public static void copy(String file1, String file2) throws Exception {
        File makeDirs = new File(file2);
        makeDirs = makeDirs.getParentFile();
        if (!makeDirs.exists()) {
            if (!makeDirs.mkdirs()) {
                throw new Exception();
            }
        }
        FileChannel in = new FileInputStream(file1).getChannel();
        FileChannel out = new FileOutputStream(file2).getChannel();
        in.transferTo(0, in.size(), out);
        in.close();
        out.close();
    }
}
